﻿using System;
using UnityEngine;

public class NodeSize : MonoBehaviour
{
    public NodeSize[] sizeList;
    private float _rw;
    private float _rh;
    private float _w;
    private float _h;
    private float _s;
    private bool _r;

    private void OnEnable()
    {
        if (!_r) return;
        Refresh(_rw, _rh, _w, _h, _s);
    }

    public void Refresh(float rw, float rh, float w, float h, float s)
    {
        _r = true;
        _rw = rw;
        _rh = rh;
        _w = w;
        _h = h;
        _s = s;
        if (!gameObject.activeSelf) return;
        OnRefresh(rw, rh, w, h, s);
        for (var i = 0; i < sizeList.Length; i++) sizeList[i].Refresh(rw, rh, w, h, s);
    }

    protected virtual void OnRefresh(float rw, float rh, float w, float h, float s)
    {
    }
}